#!/bin/bash

#echo game_set_id:$1

set_time=$(date +%s)
#echo set_time:$set_time

DBA="mysql -uroot -pqy22players -h192.168.1.237 -e"
$DBA"select gmip,gmport from yt_gm.server_list where svr_id=$1;"|grep -v '|'|grep -v ip>gm.txt

gmip=$(awk '{print $1}' gm.txt)
gmport=$(awk '{print $2}' gm.txt)
echo gmip:$gmip
echo gmport:$gmport
md5_string=`echo -n "I1e7L0F3m6u6c8O3V0n39A5xSkHdYgfvd99178a46c7c114dd782209727e986e4"|md5sum|cut -d " " -f1`

echo md5_string:$md5_string

gm_url=$gmip:$gmport

# JSON数据
json_data='{
    "cuttle": 8100,
    "game_set_id": '"${1}"',
    "channel_id": "0",
    "parm0": "65894289",
    "key_string": "I1e7L0F3m6u6c8O3V0n39A5xSkHdYgfv",
    "sign": "'"${md5_string}"'"
}'


# 目标URL
url='http://'$gm_url

# 发送POST请求，指定Content-Type为application/json
curl -X POST \
     -H "Content-Type: application/json" \
     -d "$json_data" \
     $url


sleep 5
echo 'sleep 5'

# {"cuttle":8097,"game_set_id":10501,"channel_id":"0","parm0":"1703668419","parm1":"10501","key_string":"m1I7T0y346R7p2K00228n9jkq5zPit8A","sign":"0b56a160bddb1734c8f427e56dba44a9"}.

season_id=$(($1 / 100 * 100 + 1))
echo season_id:$season_id
# JSON数据
json_data='{
    "cuttle": 8097,
    "game_set_id": '"${1}"',
    "channel_id": "0",
    "parm0": '"${set_time}"',
    "parm1": '"${season_id}"',
    "key_string": "I1e7L0F3m6u6c8O3V0n39A5xSkHdYgfv",
    "sign": "'"${md5_string}"'"
}'


# 发送POST请求，指定Content-Type为application/json
curl -X POST \
     -H "Content-Type: application/json" \
     -d "$json_data" \
     $url

rm -f gm.txt
